<template>
  <div class="permissions-container">
    <el-card class="permissions-card">
      <template #header>
        <div class="card-header">
          <span>权限管理</span>
          <el-button type="primary">添加权限</el-button>
        </div>
      </template>
      
      <el-table :data="tableData" style="width: 100%" stripe>
        <el-table-column prop="id" label="ID" width="80" />
        <el-table-column prop="name" label="权限名称" width="180" />
        <el-table-column prop="code" label="权限编码" width="180" />
        <el-table-column prop="description" label="描述" />
        <el-table-column prop="createTime" label="创建时间" width="180" />
        <el-table-column label="操作">
          <template #default="scope">
            <el-button size="small">编辑</el-button>
            <el-button size="small" type="danger">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <div class="pagination-container">
        <el-pagination
          layout="prev, pager, next"
          :total="50"
          :page-size="10"
          @current-change="handlePageChange"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import { ref } from 'vue'

export default {
  name: 'Permissions',
  setup() {
    // 模拟权限数据
    const tableData = ref([
      {
        id: 1,
        name: '用户管理',
        code: 'user.manage',
        description: '用户增删改查权限',
        createTime: '2023-01-01 12:00:00'
      },
      {
        id: 2,
        name: '角色管理',
        code: 'role.manage',
        description: '角色增删改查权限',
        createTime: '2023-01-02 12:00:00'
      },
      {
        id: 3,
        name: '权限管理',
        code: 'permission.manage',
        description: '权限增删改查权限',
        createTime: '2023-01-03 12:00:00'
      }
    ])
    
    const handlePageChange = (page) => {
      console.log('当前页:', page)
    }
    
    return {
      tableData,
      handlePageChange
    }
  }
}
</script>

<style scoped>
.permissions-container {
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pagination-container {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}
</style>